package com.alex.springbootdemo.controller;

import com.alex.springbootdemo.common.CommonResult;
import com.alex.springbootdemo.model.param.TestParam;
import com.alex.springbootdemo.model.vo.JWTToken;
import com.alex.springbootdemo.service.UmsAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/user")
@Api(tags = "UserController", description = "用户公共模块")
@AllArgsConstructor
public class UserController {

    private final UmsAdminService umsAdminService;

    @PostMapping("/refreshToken")
    @ApiOperation(value = "刷新token")
    public CommonResult refreshToken(@Valid @RequestBody UmsAdminController.RefreshTokenRequest param) {
        JWTToken token = umsAdminService.refreshToken(param);
        return CommonResult.success(token);
    }

    @PostMapping("/create")
    public CommonResult create(@RequestBody TestParam param) {
        System.out.println(param);
        return CommonResult.success(param);
    }

}
